package com.sky.controller.user;

import com.sky.constant.MessageConstant;
import com.sky.exception.BaseException;
import com.sky.result.Result;
import io.swagger.annotations.Api;
import org.springframework.data.redis.core.StringRedisTemplate;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.Mapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;

/**
 * @author zcf
 */
@RestController("userShopController")
@RequestMapping("/user/shop")
@Api(tags = "店铺相关接口")
public class ShopController {


    @Resource
    private StringRedisTemplate stringRedisTemplate;

    /**
     * 获取店铺状态
     */
    @GetMapping("/status")
    public Result<Integer> getStatus() {
        String shop_status = stringRedisTemplate.opsForValue().get("SHOP_STATUS");
        if (shop_status == null) {
            throw new BaseException(MessageConstant.SHOP_STATUS_ERROR);
        }
        return Result.success(Integer.parseInt(shop_status));
    }
}
